package files;

import gui.GUI;

import java.io.File;
import java.io.FileFilter;

public class DirFilter implements FileFilter {

	@Override
	public boolean accept(File pathname) {
		return pathname.isDirectory() && hasImages(pathname);
	}

	private boolean hasImages(File pathname) {
		File[] subs = pathname.listFiles();
		boolean ret = false;
		ImageFilter im = new ImageFilter(GUI.types);
		for(int i = 0; i < subs.length; i++) {
			if(subs[i].isDirectory() && hasImages(subs[i])) {
				ret = true;
			} else {
				if(im.accept(pathname, subs[i].getName()))
					ret = true;
			}
		}
		return ret;
	}

}
